package com.yby.mall.product.controller;

import java.util.Arrays;
import java.util.Map;

import com.yby.common.utils.PageUtils;
import com.yby.mall.product.vo.BrandVo;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.yby.mall.product.entity.BrandEntity;
import com.yby.mall.product.service.BrandService;
import com.yby.common.utils.R;



/**
 * 品牌
 *
 * @author yangbingying
 * @email 2771355658@qq.com
 * @date 2021-07-09 20:49:20
 */
@Api(value = "", tags = "品牌")
@RestController
@RequestMapping("product/brand")
public class BrandController {
    @Autowired
    private BrandService brandService;

    /**
     * 列表
     */
    @GetMapping("/list")
    public R list(Integer page,Integer limit,String key){
        return brandService.queryPage(page,limit,key);
      //  return R.ok().put("page",);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{brandId}")
    public R info(@PathVariable("brandId") Long brandId){
		BrandEntity brand = brandService.getById(brandId);

        return R.ok().put("brand", brand);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody BrandEntity brand){
		brandService.save(brand);

        return R.ok();
    }

    /**
     * 修改
     */
    @PostMapping("/update")
    public R update(@RequestBody BrandVo brand){
        return 	brandService.updateByBrand(brand);
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] brandIds){
        return brandService.delete(Arrays.asList(brandIds));
    }

    @PostMapping("/update/status")
    public R updateStatus(@RequestBody Map<String,Object> map){
        return brandService.updateStatus(map);
    }
}
